package org.biodas.jdas.creators;

import java.util.List;
import org.biodas.jdas.dassources.Capabilities;
import org.biodas.jdas.schema.sources.CAPABILITY;
import org.biodas.jdas.schema.sources.COORDINATES;
import org.biodas.jdas.schema.sources.MAINTAINER;
import org.biodas.jdas.schema.sources.ObjectFactory;
import org.biodas.jdas.schema.sources.SOURCE;
import org.biodas.jdas.schema.sources.SOURCES;
import org.biodas.jdas.schema.sources.VERSION;

public class CreateSources {
    ObjectFactory factory=new ObjectFactory();
	public SOURCES createDummySources(){
		SOURCES createSources = new SOURCES();
		SOURCE source = new SOURCE();
		String uri = "http://das.sanger.ac.uk/das/dummysource";
		source.setUri("http://das.sanger.ac.uk/das/dummysource");
		source.setDescription("Dummy Test Source, should not be in a working registry sources doc");
		VERSION version = new VERSION();
		version.setUri(uri);
		COORDINATES coord = new COORDINATES();
		coord.setAuthority("NCBI");
		coord.setSource("Chromosome");
		coord.setTaxid("9606");
		coord.setVersion("35");
		version.getCOORDINATES().add(coord);
		CAPABILITY cap = new CAPABILITY();
		cap.setQueryUri(uri + "features");
		cap.setType("das1:" + Capabilities.FEATURES.getName());
		version.getCAPABILITY().add(cap);
		source.getVERSION().add(version);
		MAINTAINER m = new MAINTAINER();
		m.setEmail("jw12@sanger.ac.uk");
		source.setMAINTAINER(m);
		source.setTitle("dummy title");
		createSources.getSOURCE().add(source);
		return createSources;
	}
        
        /**
         * Need these fields to create a source object
         * @param uri
         * @param description
         * @param title
         * @param maintainerEmail
         * @param versions - a source can have multiple versions but currently the registry and other sources don't use these - so normally only 1.
         * @return JDAS source object which needs to be added to the SOURCES object in order to be printed out as xml or json etc
         */
        public SOURCE createSource(String uri, String description,String title, String maintainerEmail, List<VERSION> versions){
            SOURCE source = new SOURCE();
            source.setUri(uri);
            source.setDescription(description);
            source.setTitle(title);
            MAINTAINER m=factory.createMAINTAINER();
            m.setEmail(maintainerEmail);
            source.setMAINTAINER(m);
            source.getVERSION().addAll(versions);
            return source;
            
        }
        
        public SOURCES  createSources(List<SOURCE> sources){
            SOURCES sourcesObj=factory.createSOURCES();  
            sourcesObj.getSOURCE().addAll(sources);
            return sourcesObj;
        }
}
